<?php
/**
 * Database
 *
 * @package scorpion-magenta
 * @author Nicky van Meurs
 * @copyright 2012
 * @version 1.0
 * @access public
 */
class Database
{
	protected static $_instance = null;

	public static function getInstance()
	{
		if (null === self::$_instance)
			try
			{
				self::$_instance = new PDO(
							'mysql:host=' . HOST . ';
				dbname=' . DB . ';
				port=' . PORT . ';
				connect_timeout=15',
							USER,
							PASS);
			}
			catch(PDOException $err )
			{
				echo $err->getMessage();
			}

		return self::$_instance;
	}

	public static function __callStatic($name, $args)
	{
		return call_user_func_array(array (self::getInstance(), $name), $args);
	}

	/**
	 * Override __clone method to prevent multiple initialization
	 */
	public function __clone() {}
}
?>